/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "local_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LocalType.findAll", query = "SELECT l FROM LocalType l"),
    @NamedQuery(name = "LocalType.findByIdLocalType", query = "SELECT l FROM LocalType l WHERE l.idLocalType = :idLocalType"),
    @NamedQuery(name = "LocalType.findByName", query = "SELECT l FROM LocalType l WHERE l.name = :name")})
public class LocalType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_LOCAL_TYPE")
    private Integer idLocalType;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "NAME")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "localType")
    private Collection<Local> localCollection;

    public LocalType() {
    }

    public LocalType(Integer idLocalType) {
        this.idLocalType = idLocalType;
    }

    public LocalType(Integer idLocalType, String name) {
        this.idLocalType = idLocalType;
        this.name = name;
    }

    public Integer getIdLocalType() {
        return idLocalType;
    }

    public void setIdLocalType(Integer idLocalType) {
        this.idLocalType = idLocalType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<Local> getLocalCollection() {
        return localCollection;
    }

    public void setLocalCollection(Collection<Local> localCollection) {
        this.localCollection = localCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLocalType != null ? idLocalType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LocalType)) {
            return false;
        }
        LocalType other = (LocalType) object;
        if ((this.idLocalType == null && other.idLocalType != null) || (this.idLocalType != null && !this.idLocalType.equals(other.idLocalType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.LocalType[ idLocalType=" + idLocalType + " ]";
    }
    
}
